package com.gao.c_publisher_subscribe;

import org.springframework.amqp.core.ExchangeTypes;
import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.QueueBinding;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

/**
 * @author gao
 * @time 2022/07/05 10:34:15
 */
//@Component
public class Consumer {

    @RabbitListener(
            bindings = {
                    @QueueBinding(
                            value = @Queue, // 创建临时队列
                            exchange = @Exchange(value = "logs", type = ExchangeTypes.FANOUT) // 绑定的交换机
                    )
            }
    )
    public void receive(String msg) {
        System.out.println("A: " + msg);
    }


    @RabbitListener(
            bindings = {
                    @QueueBinding(
                            value = @Queue, // 创建临时队列
                            exchange = @Exchange(value = "logs", type = ExchangeTypes.FANOUT) // 绑定的交换机
                    )
            }
    )
    public void receive2(String msg) {
        System.out.println("B: " + msg);
    }
}
